import requests

from crawlers.tiktok.marketplace.lib.utils import get_x_bogus
from urllib.parse import urlencode

headers = {
    "authority": "www.douyin.com",
    "accept": "application/json, text/plain, */*",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "pragma": "no-cache",
    "referer": "https://www.douyin.com/user/MS4wLjABAAAAAXErEMSrS1mwzQME4VAZnp7h92vd93EgDb-PTLjbRi0",
    "sec-ch-ua": "\"Not A(Brand\";v=\"99\", \"Google Chrome\";v=\"121\", \"Chromium\";v=\"121\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"macOS\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
}
cookies = {
    "csrf_session_id": "c28c333ae228508dbf5756d278a4d7fb",
    "bd_ticket_guard_client_web_domain": "2",
    "passport_csrf_token": "d800d5a157d1ad45b968e01d638b2b7f",
    "passport_csrf_token_default": "d800d5a157d1ad45b968e01d638b2b7f",
    "xgplayer_user_id": "846187686444",
    "douyin.com": "",
    "xg_device_score": "7.658235294117647",
    "device_web_cpu_core": "8",
    "device_web_memory_size": "8",
    "n_mh": "mvloHaTRGFNtlPkmYyBV9t_kDrBgqLtRMtd_oTZAeVE",
    "LOGIN_STATUS": "1",
    "_bd_ticket_crypt_doamin": "2",
    "__security_server_data_status": "1",
    "dy_sheight": "900",
    "FORCE_LOGIN": "%7B%22videoConsumedRemainSeconds%22%3A180%2C%22isForcePopClose%22%3A1%7D",
    "publish_badge_show_info": "%220%2C0%2C0%2C1708133433455%22",
    "s_v_web_id": "verify_lspekap4_04675036_bdae_b3d7_3335_94c1441093c0",
    "sso_auth_status": "2c229616c788bd4b7751bc0e632e9fa8",
    "sso_auth_status_ss": "2c229616c788bd4b7751bc0e632e9fa8",
    "volume_info": "%7B%22isUserMute%22%3Afalse%2C%22isMute%22%3Atrue%2C%22volume%22%3A0.6%7D",
    "SEARCH_RESULT_LIST_TYPE": "%22single%22",
    "download_guide": "%223%2F20240219%2F1%22",
    "__live_version__": "%221.1.1.8009%22",
    "webcast_local_quality": "null",
    "live_use_vvc": "%22false%22",
    "pwa2": "%220%7C0%7C3%7C1%22",
    "ttwid": "1%7Ckx5P7h8WG4W_5rl5FeEp4-gNSAJZC_He3x0l8kzBhDI%7C1708393084%7C72ea20d85e6ff8d5e71a0541f209ce3a9c1d785cda0dde4a19ef2f0c218b203c",
    "sso_uid_tt": "284d1fa8169af73ec4c1dc69e7f31c10",
    "sso_uid_tt_ss": "284d1fa8169af73ec4c1dc69e7f31c10",
    "toutiao_sso_user": "93af831c9184dab2e21548fa1e87d2a5",
    "toutiao_sso_user_ss": "93af831c9184dab2e21548fa1e87d2a5",
    "webcast_leading_last_show_time": "1708417265358",
    "webcast_leading_total_show_times": "2",
    "store-region-src": "uid",
    "passport_assist_user": "CkGNGp3ml0ZTEi4-y-9XDLQwRcfCMQ9PFFjQPJ6jSt3t09SFb8qjOALRiKDAMCLHHIYFJnWuE9-lcdlpGi3mCuHAYRpKCjzK-YyMsZMl9p2HMzVTr1dJKM1YCaVhaPSDeIGLEnELAVkJnzMhi37GKnRl_kN9yTrODaQ71ojb5XeUyZIQwvvJDRiJr9ZUIAEiAQNe5q9w",
    "sid_ucp_sso_v1": "1.0.0-KDVkMWM4ZTUwYmQxNWRjMTBjZWIyMWFlNGZjY2I2YzA3YmFiYzE2NmYKHwjI1MDxhvTbBhC_otauBhjvMSAMML3Hm_gFOAZA9AcaAmxmIiA5M2FmODMxYzkxODRkYWIyZTIxNTQ4ZmExZTg3ZDJhNQ",
    "ssid_ucp_sso_v1": "1.0.0-KDVkMWM4ZTUwYmQxNWRjMTBjZWIyMWFlNGZjY2I2YzA3YmFiYzE2NmYKHwjI1MDxhvTbBhC_otauBhjvMSAMML3Hm_gFOAZA9AcaAmxmIiA5M2FmODMxYzkxODRkYWIyZTIxNTQ4ZmExZTg3ZDJhNQ",
    "passport_auth_status": "9e104d0e2582f7a50b5d4a6fa77711f6%2Cc99143c71d865d68f8f328fc3df6d197",
    "passport_auth_status_ss": "9e104d0e2582f7a50b5d4a6fa77711f6%2Cc99143c71d865d68f8f328fc3df6d197",
    "uid_tt": "3bd35edc895593ed6bafb56ba909c5ed",
    "uid_tt_ss": "3bd35edc895593ed6bafb56ba909c5ed",
    "sid_tt": "65836e742ecf1a23829c9a55568e60d4",
    "sessionid": "65836e742ecf1a23829c9a55568e60d4",
    "sessionid_ss": "65836e742ecf1a23829c9a55568e60d4",
    "_bd_ticket_crypt_cookie": "1fdd533bd75cfbb399ae8a0fe5a62d36",
    "sid_guard": "65836e742ecf1a23829c9a55568e60d4%7C1708495179%7C5183991%7CSun%2C+21-Apr-2024+05%3A59%3A30+GMT",
    "sid_ucp_v1": "1.0.0-KGUxNzNjNDFmMzNmMjdiMTc3YjkyOWM1OTZkNmE0NjFkOTVkM2ZlY2YKGwjI1MDxhvTbBhDLotauBhjvMSAMOAZA9AdIBBoCbHEiIDY1ODM2ZTc0MmVjZjFhMjM4MjljOWE1NTU2OGU2MGQ0",
    "ssid_ucp_v1": "1.0.0-KGUxNzNjNDFmMzNmMjdiMTc3YjkyOWM1OTZkNmE0NjFkOTVkM2ZlY2YKGwjI1MDxhvTbBhDLotauBhjvMSAMOAZA9AdIBBoCbHEiIDY1ODM2ZTc0MmVjZjFhMjM4MjljOWE1NTU2OGU2MGQ0",
    "dy_swidth": "1600",
    "my_rd": "2",
    "__ac_nonce": "065d5ac1800db9fadc5b3",
    "__ac_signature": "_02B4Z6wo00f0169sAvwAAIDCQUnGAP0xXxuvTAZAAI4X7iLA2CisbIKkM.rQ24eH79Lk5z2VTs6cndSqDZPwSkLSSIMy9k.JVhXjdPAy7vtJAS0.1xd0ndw.UgJy6JaSHxmKVgdRckKY3t8Y68",
    "strategyABtestKey": "%221708502070.208%22",
    "store-region": "cn-cq",
    "_tea_utm_cache_1243": "undefined",
    "MONITOR_WEB_ID": "32b76556-3867-4365-aa42-42b061b226f8",
    "live_can_add_dy_2_desktop": "%221%22",
    "passport_fe_beating_status": "true",
    "stream_recommend_feed_params": "%22%7B%5C%22cookie_enabled%5C%22%3Atrue%2C%5C%22screen_width%5C%22%3A1600%2C%5C%22screen_height%5C%22%3A900%2C%5C%22browser_online%5C%22%3Atrue%2C%5C%22cpu_core_num%5C%22%3A4%2C%5C%22device_memory%5C%22%3A8%2C%5C%22downlink%5C%22%3A10%2C%5C%22effective_type%5C%22%3A%5C%224g%5C%22%2C%5C%22round_trip_time%5C%22%3A250%7D%22",
    "FOLLOW_LIVE_POINT_INFO": "%22MS4wLjABAAAAFEVb9X6QxfMONdN3GpBxEs70X4vCKAm19nUnsgniSUTEKh-2V4mi1dl1dWCA-mCy%2F1708531200000%2F0%2F0%2F1708503792348%22",
    "FOLLOW_NUMBER_YELLOW_POINT_INFO": "%22MS4wLjABAAAAFEVb9X6QxfMONdN3GpBxEs70X4vCKAm19nUnsgniSUTEKh-2V4mi1dl1dWCA-mCy%2F1708531200000%2F0%2F0%2F1708504392350%22",
    "bd_ticket_guard_client_data": "eyJiZC10aWNrZXQtZ3VhcmQtdmVyc2lvbiI6MiwiYmQtdGlja2V0LWd1YXJkLWl0ZXJhdGlvbi12ZXJzaW9uIjoxLCJiZC10aWNrZXQtZ3VhcmQtcmVlLXB1YmxpYy1rZXkiOiJCQjV4U21tcUdITkx0QVN2NHZ6N3VsZ3hDeXlzTXBSdTBBYnNXVkwvVFpveUxLdjR3ZmtZV3RBRGdaVlhtNERDOGRGblBMQlhIRjF4YURqUzUyb0duZk09IiwiYmQtdGlja2V0LWd1YXJkLXdlYi12ZXJzaW9uIjoxfQ%3D%3D",
    "odin_tt": "dcd076d34c213ff78f224cb9d082e470c7a671bbe40da6a58137a14a7c650d36b0e3b4e908caf780ba1d6999e33f69626d7da9b5c5c583191b165d65f0869368",
    "tt_scid": "mn2CjC1j9MqK6rDH32ZxSBEO2nhK02uo9vFzkNln.iYNGiwmWXpVOLdBbvyDfPPm4380",
    "msToken": "CO6RjjwuSxH71oMc6AEDSrsV2b-N5DadXuxXFdu8_x5fZyoVDj6ukleP5wCg5vjbiA6cGXW2CRSivwjv-ZPCJaW63KvYncpeywOLVlq8l0cKGTPKr1k=",
    "IsDouyinActive": "true",
    "home_can_add_dy_2_desktop": "%220%22"
}
url = "https://www.douyin.com/aweme/v1/web/user/profile/other/"
sec_user_id = 'MS4wLjABAAAAy-LgndOAf2KYJskVX1de39p5ntFVFu4puJYVPgyuf30'
params = {
    "device_platform": "webapp",
    "aid": "6383",
    "channel": "channel_pc_web",
    "publish_video_strategy_type": "2",
    "source": "channel_pc_web",
    "sec_user_id": sec_user_id,

    "personal_center_strategy": "1",
    "pc_client_type": "1",
    "version_code": "170400",
    "version_name": "17.4.0",
    "cookie_enabled": "true",
    "screen_width": "1600",
    "screen_height": "900",
    "browser_language": "zh-CN",
    "browser_platform": "MacIntel",
    "browser_name": "Chrome",
    "browser_version": "121.0.0.0",
    "browser_online": "true",
    "engine_name": "Blink",
    "engine_version": "121.0.0.0",
    "os_name": "Mac OS",
    "os_version": "10.15.7",
    "cpu_core_num": "4",
    "device_memory": "8",
    "platform": "PC",
    "downlink": "10",
    "effective_type": "4g",
    "round_trip_time": "250",
    "webid": "7329725479883605544",
    "msToken": "RVk4zHzk8u6yBkBqA1Rx05XBBNAaLDd6G-F3UJS7upEFGBp5u7z5vVz9IIdYjTrUIBzFaJ9FAb8q1Wea79CItHD_BP2wcGnI_HWgg_9RxqDctr5halTFdLmfSk9UzXg=",
}
x_bogus = get_x_bogus(params=params, data='', useragent=headers['user-agent'])
params['X-Bogus'] = x_bogus
response = requests.get(url, headers=headers, cookies=cookies, params=params)

print(response.text)
